import {createRouter, createWebHistory} from 'vue-router'
import Layout from '@/Layout/index.vue'

export let constantRoutes = [
    {
        path: '/',
        name: 'Layout',
        redirect: '/home',
        component: Layout,
        children: [
            {
                path: '/home',
                name: 'Home',
                meta: {
                    title: '首页',
                    icon: 'icon-home',
                },
                component: () => import('@/views/Home/index.vue'),
            }
        ]
    },
    {
        path: '/login',
        name: 'Login',
        hidden: true,
        component: () => import('@/views/Login/index.vue')
    },
    {
        path: '/404',
        name: 'NoPage404',
        component: () => import('@/views/404.vue'),
        hidden: true
    },
]

export const errorRoutes = [
    {
        path: '/:pathMatch(.*)',
        redirect: '/404',
        hidden: true
    }
]

const router = createRouter({
    routes: constantRoutes,
    history: createWebHistory(),
})

export default router
